
WindSegmentedModel = function() {
	this.buttons = new Array(); 
}

WindSegmentedModel.prototype.addButton = function(button) {
	this.buttons[this.buttons.length] = button;
}

WindSegmentedModel.prototype.getButton = function(index) {
	return this.buttons[index];
}

WindSegmentedModel.prototype.getNumberOfButtons = function() {
	return this.buttons.length;
}

WindSegmentedModel.prototype.createButton = function() {
	var button = WindButton.createModel();
	this.addButton(button);
	return button;
}


var WindSegmented = new Object();

WindSegmented.createModel = function() {
	return new WindSegmentedModel();
}

WindSegmented.createView = function(segmentedModel) {
	var segmentedView = new WindView();
	segmentedView.setCssClass("WindSegmented");
	
	segmentedView.createHtmlElement = function() {
		var table = document.createElement("table");
		table.cellSpacing = 0;
		table.cellPadding = 0;
		return table;
	}
	
	var entriesView = new WindView();
	entriesView.setCssClass("WindSegmentedEntries");
	segmentedView.addView(entriesView);
	
	entriesView.createHtmlElement = function() {
		var tr = document.createElement("tr");
		return tr;
	}
	
	for(var i=0; i<segmentedModel.getNumberOfButtons(); i++) {
		var buttonModel = segmentedModel.getButton(i);
		var buttonView = WindButton.createView(buttonModel);
		
		entriesView.addView(buttonView);
		
		buttonView.createHtmlElement = function() {
			var td = document.createElement("td");
			return td;
		}
	}
	
	return segmentedView;
}

